Appearance
KBE3D / KBCore / Cesium / Math
Math
Math functions.
函数
| 函数 | 描述 |
|---|---|
| sign | Returns the sign of the value; 1 if the value is positive, -1 if the value is negative, or 0 if the value is 0. |
| signNotZero | Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative. This is similar to Math#sign except that returns 1.0 instead of 0.0 when the input value is 0.0. |
| toSNorm | Converts a scalar value in the range [-1.0, 1.0] to a SNORM in the range [0, rangeMaximum] |
| fromSNorm | Converts a SNORM value in the range [0, rangeMaximum] to a scalar in the range [-1.0, 1.0]. |
| normalize | Converts a scalar value in the range [rangeMinimum, rangeMaximum] to a scalar in the range [0.0, 1.0] |
| sinh | Returns the hyperbolic sine of a number. The hyperbolic sine of value is defined to be (ex - e-x)/2.0 where e is Euler's number, approximately 2.71828183. |
| cosh | Returns the hyperbolic cosine of a number. The hyperbolic cosine of value is defined to be (ex + e-x)/2.0 where e is Euler's number, approximately 2.71828183. |
| lerp | Computes the linear interpolation of two values. |
| toRadians | Converts degrees to radians. |
| toDegrees | Converts radians to degrees. |
| convertLongitudeRange | Converts a longitude value, in radians, to the range [-Math.PI, Math.PI). |
| clampToLatitudeRange | Convenience function that clamps a latitude value, in radians, to the range [-Math.PI/2, Math.PI/2). Useful for sanitizing data before use in objects requiring correct range. |
| negativePiToPi | Produces an angle in the range -Pi <= angle <= Pi which is equivalent to the provided angle. |
| zeroToTwoPi | Produces an angle in the range 0 <= angle <= 2Pi which is equivalent to the provided angle. |
| mod | The modulo operation that also works for negative dividends. |
| equalsEpsilon | Determines if two values are equal using an absolute or relative tolerance test. This is useful to avoid problems due to roundoff error when comparing floating-point values directly. The values are first compared using an absolute tolerance test. If that fails, a relative tolerance test is performed. Use this test if you are unsure of the magnitudes of left and right. |
| lessThan | Determines if the left value is less than the right value. If the two values are within absoluteEpsilon of each other, they are considered equal and this function returns false. |
| lessThanOrEquals | Determines if the left value is less than or equal to the right value. If the two values are within absoluteEpsilon of each other, they are considered equal and this function returns true. |
| greaterThan | Determines if the left value is greater the right value. If the two values are within absoluteEpsilon of each other, they are considered equal and this function returns false. |
| greaterThanOrEquals | Determines if the left value is greater than or equal to the right value. If the two values are within absoluteEpsilon of each other, they are considered equal and this function returns true. |
| factorial | Computes the factorial of the provided number. |
| incrementWrap | Increments a number with a wrapping to a minimum value if the number exceeds the maximum value. |
| isPowerOfTwo | Determines if a non-negative integer is a power of two. The maximum allowed input is (2^32)-1 due to 32-bit bitwise operator limitation in Javascript. |
| nextPowerOfTwo | Computes the next power-of-two integer greater than or equal to the provided non-negative integer. The maximum allowed input is 2^31 due to 32-bit bitwise operator limitation in Javascript. |
| previousPowerOfTwo | Computes the previous power-of-two integer less than or equal to the provided non-negative integer. The maximum allowed input is (2^32)-1 due to 32-bit bitwise operator limitation in Javascript. |
| clamp | Constraint a value to lie between two values. |
| setRandomNumberSeed | Sets the seed used by the random number generator in Math#nextRandomNumber. |
| nextRandomNumber | Generates a random floating point number in the range of [0.0, 1.0) using a Mersenne twister. |
| randomBetween | Generates a random number between two numbers. |
| acosClamped | Computes Math.acos(value), but first clamps value to the range [-1.0, 1.0] so that the function will never return NaN. |
| asinClamped | Computes Math.asin(value), but first clamps value to the range [-1.0, 1.0] so that the function will never return NaN. |
| chordLength | Finds the chord length between two points given the circle's radius and the angle between the points. |
| logBase | Finds the logarithm of a number to a base. |
| cbrt | Finds the cube root of a number. Returns NaN if number is not provided. |
| log2 | Finds the base 2 logarithm of a number. |
| fastApproximateAtan | Computes a fast approximation of Atan for input in the range [-1, 1]. |
| fastApproximateAtan2 | Computes a fast approximation of Atan2(x, y) for arbitrary input scalars. |
变量
| 变量 | 描述 |
|---|---|
| EPSILON1 | 0.1 |
| EPSILON2 | 0.01 |
| EPSILON3 | 0.001 |
| EPSILON4 | 0.0001 |
| EPSILON5 | 0.00001 |
| EPSILON6 | 0.000001 |
| EPSILON7 | 0.0000001 |
| EPSILON8 | 0.00000001 |
| EPSILON9 | 0.000000001 |
| EPSILON10 | 0.0000000001 |
| EPSILON11 | 0.00000000001 |
| EPSILON12 | 0.000000000001 |
| EPSILON13 | 0.0000000000001 |
| EPSILON14 | 0.00000000000001 |
| EPSILON15 | 0.000000000000001 |
| EPSILON16 | 0.0000000000000001 |
| EPSILON17 | 0.00000000000000001 |
| EPSILON18 | 0.000000000000000001 |
| EPSILON19 | 0.0000000000000000001 |
| EPSILON20 | 0.00000000000000000001 |
| EPSILON21 | 0.000000000000000000001 |
| GRAVITATIONALPARAMETER | The gravitational parameter of the Earth in meters cubed per second squared as defined by the WGS84 model: 3.986004418e14 |
| SOLAR_RADIUS | Radius of the sun in meters: 6.955e8 |
| LUNAR_RADIUS | The mean radius of the moon, according to the "Report of the IAU/IAG Working Group on Cartographic Coordinates and Rotational Elements of the Planets and satellites: 2000", Celestial Mechanics 82: 83-110, 2002. |
| SIXTY_FOUR_KILOBYTES | 64 * 1024 |
| FOUR_GIGABYTES | 4 * 1024 * 1024 * 1024 |
| PI | pi |
| ONE_OVER_PI | 1/pi |
| PI_OVER_TWO | pi/2 |
| PI_OVER_THREE | pi/3 |
| PI_OVER_FOUR | pi/4 |
| PI_OVER_SIX | pi/6 |
| THREE_PI_OVER_TWO | 3pi/2 |
| TWO_PI | 2pi |
| ONE_OVER_TWO_PI | 1/2pi |
| RADIANS_PER_DEGREE | The number of radians in a degree. |
| DEGREES_PER_RADIAN | The number of degrees in a radian. |
| RADIANS_PER_ARCSECOND | The number of radians in an arc second. |
